home *** CD-ROM | disk | FTP | other *** search
- Path: erich.triumf.ca!bennett
- From: bennett@erich.triumf.ca (P.Bennett)
- Newsgroups: comp.lang.c
- Subject: Re: Pointers to register
- Date: 18 Mar 1996 07:59 PST
- Organization: TRIUMF: Tri-University Meson Facility
- Distribution: world
- Message-ID: <18MAR199607594276@erich.triumf.ca>
- References: <1239@altheim.win-uk.net>
- NNTP-Posting-Host: erich.triumf.ca
- News-Software: VAX/VMS VNEWS 1.50
-
- In article <1239@altheim.win-uk.net>, broldham@altheim.win-uk.net (Brian R. Oldham) writes...
- >A couple of weeks ago someone posted the opinion that all objects in
- >memory must have an address, which might have gone uncontested but for
- >the fact that he added that therefore all pointers must point to an
- >address. Someone else reminded us that registers don't have an address.
- >
- >Bearing in mind the usual way to assign a pointer:
- >
- > ptr = &var;
- >
- >is correct for objects in memory, but how do you assign a pointer
- >to a register?
-
- You don't - a register doesn't have a memory address.
-
- >The following function (a getch() for x86) works: But is it right??
-
- >static union REGS inregs, outregs;
-
- >void getkey(int *scancode, char *ch)
- >{
- > inregs.h.ah = 0x00;
- > int86(KEYBD,&inregs,&outregs);
- > *scancode = outregs.h.ah; /* ??? */
-
- This is not referencing a register - outregs is a union the compiler provides
- to allow the user to provide the values used to set the registers before
- calling int86(), or to store the return values from that function.
-
- If you declare a variable as:
- register int i;
- you are promising the compiler that you will not try to create a pointer to i,
- and also suggesting that the compiler may want to put i in a processor
- register, rather than on the stack ( or whereever it would otherwise go).
-
-
- Peter Bennett VE7CEI | Vessels shall be deemed to be in sight
- Internet: bennett@triumf.ca | of one another only when one can be
- Packet: ve7cei@ve7kit.#vanc.bc.ca | observed visually from the other
- TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k)
- GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
- or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-